//用于测试的api
import request from '@/utils/httpRequest/request'

const api = {
    test: '/test',
    getNews: '/api/article/news',
    getRumors: '/api/article/rumors',
    login: '/api/user/login',
    register: '/api/user/register',
    changeinfo: '/api/user/reset/emandun',
    changepass: '/api/user/reset/password',
    upload: '/api/file/upload',
    getairesponce: '/api/ai/getresponse',
    applyAuth: '/api/user/certification'
}

export const common = {

    login: function(email, password) {
        return request({
            url: api.login,
            method: 'post',
            data: {
                email: email,
                password: password
            }
        })
    },
    register: function(email, username, password) {
        return request({
            url: api.register,
            method: 'post',
            data: {
                email: email,
                username: username,
                password: password
            }
        })
    },
    resetemandun: function(id, username, email) {
        return request({
            url: api.changeinfo,
            method: 'post',
            data: {
                id: id,
                username: username,
                email: email
            }
        })
    },
    resetpass: function(email, oldPassword, newPassword) {
        return request({
            url: api.changepass,
            method: 'post',
            data: {
                email: email,
                oldPassword: oldPassword,
                newPassword: newPassword
            }
        })
    },
    uploadPicture: function(file) {
        let formData = new FormData();
        formData.append("picture", file);
        return request({
            url: api.upload,
            data: formData,
            method: 'post',
        })
    },
    getResponce: function(query) {
        return request({
            url: api.getairesponce + "?query=" + query,
            method: 'get',
        })
    },
    applyAuth:function(params){
        return request({
            url:api.applyAuth,
            data: params,
            method:"post",
        });
    }

}